package org.jeecg.modules.workflow.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.workflow.entity.BpmTaskExt;

import java.util.Collection;
import java.util.List;

/**
 * 工作流的流程任务的拓展Mapper接口
 *
 * @author whnk
 * @date 2022-04-20
 */
public interface BpmTaskExtMapper extends BaseMapper<BpmTaskExt>
{

    default void updateByTaskId(BpmTaskExt entity) {
        update(entity, new LambdaQueryWrapper<BpmTaskExt>().eq(BpmTaskExt::getTaskId, entity.getTaskId()));
    }

    default List<BpmTaskExt> selectListByTaskIds(Collection<String> taskIds) {
        return selectList(new LambdaQueryWrapper<BpmTaskExt>().in(BpmTaskExt::getTaskId, taskIds));
    }

    default List<BpmTaskExt> selectListByProcessInstanceId(String processInstanceId) {
        return selectList(new QueryWrapper<BpmTaskExt>().eq("process_instance_id", processInstanceId));
    }

    default BpmTaskExt selectByTaskId(String taskId) {
        return selectOne(new LambdaQueryWrapper<BpmTaskExt>().eq(BpmTaskExt::getTaskId, taskId));
    }
}
